import { defineConfig} from "vite";
import vue from '@vitejs/plugin-vue'
import federation from "@originjs/vite-plugin-federation";
import AutoImport from "unplugin-auto-import/vite"; // 自动导入
import qiankun from 'vite-plugin-qiankun'

export default defineConfig({
 server: {
    port: 5555,
    host: '0.0.0.0',
    open: true,
    cors: false, 
    fs: {
      strict: true
    },
    headers: {
      'Access-Control-Allow-Origin': '*',
			'Access-Control-Allow-Headers': '*',
			'Access-Control-Allow-Methods': '*'
    },
     origin: 'http://localhost:5555'
 },
 base: process.env.NODE_ENV === 'production' ? "/vue-app" : '/',
 plugins: [
    vue(),
    qiankun('vue-app', {
      useDevMode: true
    }),
    AutoImport(),
    federation({
      name: "vue-app",  
      remotes: {
         "base": "http://localhost:3000/dist/assets/remoteEntry.js", 
      },
      shared: {
        vue: {
            requiredVersion: "^3.2.45"
        },
        pinia: {
            singleton: true,
            requiredVersion: "^2.2.6"
        }
       
      }
    })  
  ],
  build: {
    target: 'esnext',
    minify: false,
    cssCodeSplit: false,
    rollupOptions: {
      output: {
        minifyInternalExports: false
      }
    }
  },
  resolve: {
    extensions: ['.js', '.vue', '.json', ".ts", ".tsx", ".jsx", ".json"], // 添加文件扩展名解析
    alias: {
      '@': '/src', // 配置路径别名
    },
    
  }

})